<?php
/**
 * @copyright Arthur Beer
 * @package image
 *
 * @copyright TinyWEB CMS
 * @link http://tinywebcms.ru
 * @link http://cms.vingrad.ru
 * @version SVN: $Id$ 
 */
 
/**
 * ImageRemoteLinksGrabber
 */
class ImageRemoteLinksGrabber extends ArrayObject 
{
    protected $text;
    
    public function __construct($text)
    {
        $this->text = $text;
        
        if(preg_match_all("/http:\/\/[a-z0-9-\.]+\/[a-z0-9\/_\.-]+\.(jpg|jpeg|jpe|gif|png)/ius", $this->text, $matches)) {
            foreach ($matches[0] as $url) {
                if(mb_strpos($url, "http://lovemypet.ru") === false) {
                    $this->append($url);
                }
            }
        }
    }
    
    public function replace($url, $new_url)
    {
        $this->text = str_replace($url, $new_url, $this->text);
    }
    
    public function getText()
    {
        return $this->text;
    }
}

/**
 * Tab: 4 spaces
 * Encoding: utf-8
 */
?>